<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" autoFlush="true"%>
<%@include file="/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<x:multiLanguage>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../css/dialog.css" rel="stylesheet" type="text/css" />
<link href="../css/ddtabmenu_dialog.css" rel="stylesheet" type="text/css" />

<script src="common/fck_dialog_common.js" type="text/javascript"></script>
<script language="JavaScript" src="dialog.js"></script>
<script language="JavaScript" src="script.js"></script>
<script language="JavaScript" src="sequence.js"></script>

<script language="JavaScript" src='<s:url value="/script/jquery/jquery-1.4.2.js" />'></script>
<script language="JavaScript" src='<s:url value="/script/ddtabmenufiles/ddtabmenu.js" />'></script>

<SCRIPT language="JavaScript">
	var dialog = window.parent;
	var oEditor = dialog.InnerDialogLoaded();
	var oDOM = oEditor.FCK.EditorDocument;
	var oActiveEl = dialog.Selection.GetSelectedElement();

	// 选项卡点击事件
	function cardClick(cardID) {
		var obj;
		for ( var i = 1; i < 8; i++) {
			obj = document.all("card" + i);
			obj.style.backgroundColor = "#3A6EA5";
			obj.style.color = "#FFFFFF";
		}
		obj = document.all("card" + cardID);
		obj.style.backgroundColor = "#FFFFFF";
		obj.style.color = "#3A6EA5";

		for ( var i = 1; i < 8; i++) {
			obj = document.all("content" + i);
			obj.style.display = "none";
		}
		obj = document.all("content" + cardID);
		obj.style.display = "";
		resize();
	}

	//初始值
	function InitDocument() {
		var editMode;
		oEditor.FCKLanguageManager.TranslatePage(document);
		//ev_init('content.type','_onactionviewid','_onactionformid','_onactionflowid');

		if (oActiveEl) {
			if(oActiveEl.name!=null){
				temp.name.value = HTMLDencode(oActiveEl.name);
			}

			if(oActiveEl.discript!=null){
				temp.discript.value = HTMLDencode(oActiveEl.discript);
			}


			if(oActiveEl.valueScript!=null){
				temp.valueScript.value = HTMLDencode(oActiveEl.valueScript);
			}

			if(oActiveEl.optionsScript!=null){
				temp.optionsScript.value = HTMLDencode(oActiveEl.optionsScript);
			}

			if(oActiveEl.validateRule!=null){
				temp.validateRule.value = HTMLDencode(oActiveEl.validateRule);
			}

			if(oActiveEl.hiddenScript!=null){
				temp.hiddenScript.value = HTMLDencode(oActiveEl.hiddenScript);
			}

			if(oActiveEl.hiddenValue!=null){
				temp.hiddenValue.value = HTMLDencode(oActiveEl.hiddenValue);
			}

			if(oActiveEl.filtercondition!=null){
				temp.filtercondition.value = HTMLDencode(oActiveEl.filtercondition);
			}

			if(oActiveEl.readonlyScript!=null){
				temp.readonlyScript.value = HTMLDencode(oActiveEl.readonlyScript);
			}

			if(oActiveEl.hiddenPrintScript!=null){
				temp.hiddenPrintScript.value = HTMLDencode(oActiveEl.hiddenPrintScript);
			}

			if(oActiveEl.printHiddenValue!=null){
				temp.printHiddenValue.value = HTMLDencode(oActiveEl.printHiddenValue);
			}

			if(oActiveEl.refreshOnChanged!=null){
				temp.refreshOnChanged.checked = oActiveEl.refreshOnChanged == "true";
			}else{
				temp.refreshOnChanged.checked = false;
			}

			if(oActiveEl.calculateOnRefresh!=null){
				temp.calculateOnRefresh.checked = oActiveEl.calculateOnRefresh == "true";
			}else{
				oActiveEl.calculateOnRefresh
			}

			if(oActiveEl.mobile!=null){
				temp.mobile.checked = oActiveEl.mobile == "true";
			}else{
				temp.mobile.checked = false;
			}

			if(oActiveEl.editMode!=null){
				editMode = HTMLDencode(oActiveEl.editMode);
			}

			if(oActiveEl.processDescription!=null){
				var items = HTMLDencode(oActiveEl.processDescription);
				parseRelStr(items);
			}

			
			if (oActiveEl.textType == null) {
				oActiveEl.textType = 'text';

			}
			temp.textType.value = HTMLDencode(oActiveEl.textType);

			if(oActiveEl.validateLibs!=null){
				var libstr = HTMLDencode(oActiveEl.validateLibs);
				var lib = libstr.split(';');
				var validateLibs = document.getElementsByName('validateLibs');
				for ( var i = 0; i < lib.length; i++) {
					for ( var j = 0; j < validateLibs.length; j++) {
						if (validateLibs[j].value == lib[i]) {
							validateLibs[j].checked = true;
						}
					}
				}
			}
		} else
			oActiveEl = null;
		dialog.SetOkButton(true);
		dialog.SetAutoSize(true);
		SelectField('name');
		initForm();
		modeChange(editMode);
		resize();
		window.top.toThisHelpPage("application_module_form_info_advance_select");
	}

	//OK方法
	function Ok() {
		oEditor.FCKUndo.SaveUndoStep();
		var className = "cn.myapps.core.dynaform.form.ejb.SelectField";
		var id = "";
		
		var editMode = document.getElementsByName("editMode");
		var ed = "";
		for ( var i = 0; i < editMode.length; i++) {
			if (editMode[i].checked) {
				ed += editMode[i].value;
			}
		}
		var validateLibs = document.getElementsByName('validateLibs');
		var libs = '';
		for ( var i = 0; i < validateLibs.length; i++) {
			if (validateLibs[i].checked) {
				libs += validateLibs[i].value + ";";
			}
		}
		libs = libs.substring(0, libs.length - 1);

		oActiveEl = CreateNamedElement(
				oEditor,
				oActiveEl,
				'select',
				{
					classname :className,
					id :id,
					name :GetE('name').value,
					discript :HTMLEncode(temp.discript.value),
					valueScript :HTMLEncode(temp.valueScript.value),
					optionsScript :HTMLEncode(temp.optionsScript.value),
					validateRule :HTMLEncode(temp.validateRule.value),
					hiddenScript:HTMLEncode(temp.hiddenScript.value),
					hiddenValue:HTMLEncode(temp.hiddenValue.value),//////
					hiddenPrintScript:HTMLEncode(temp.hiddenPrintScript.value),
					printHiddenValue:HTMLEncode(temp.printHiddenValue.value),
					textType :HTMLEncode(temp.textType.value),
					readonlyScript :HTMLEncode(temp.readonlyScript.value),
					fieldtype :"VALUE_TYPE_VARCHAR",
					processDescription :HTMLEncode(createRelStr()),
					filtercondition :HTMLEncode(temp.filtercondition.value),
					refreshOnChanged :HTMLEncode(temp.refreshOnChanged.checked
							+ ""),
					calculateOnRefresh :HTMLEncode(temp.calculateOnRefresh.checked
							+ ""),
					mobile :HTMLEncode(temp.mobile.checked + ""),
					validateLibs :HTMLEncode(libs),
					editMode :HTMLEncode(ed),
					processDescription :HTMLEncode(createRelStr())
				});
		return true;
	}

	//检查内容是否完成正确
	function ev_check() {
		if (temp.name.value == '') {
			alert("{*[page.name.notexist]*}");
			return false;
		}
		return !checkStartChar(temp.name.value);
	}

	function checkStartChar(value) {
		return true;
		//return IsDigit(value, "{*[page.name.startingit]*}");
	}
</script>

	</HEAD>

	<BODY onload="InitDocument()">

	<form name="temp">
	<table border=0 cellpadding=3 cellspacing=0>
		<tr>
			<td class="card" onclick=cardClick(1);; id="card1">{*[Basic]*}</td>
			<td width=2></td>
			<td class="card" onclick=cardClick(2);; id="card2">{*[Value_Script]*}</td>
			<td width=2></td>
			<td class="card" onclick=cardClick(3);; id="card3">{*[Option_Script]*}</td>
			<td width=2></td>
			<td class="card" onclick=cardClick(4);; id="card4">{*[Validate_Script]*}</td>
			<td width=2></td>
			<td class="card" onclick=cardClick(5);; id="card5">{*[Hidden_Script]*}</td>
			<td width=2></td>
			<td class="card" onclick=cardClick(6);; id="card6">{*[Hidden_Print_Script]*}</td>
			<td width=2></td>
			<td class="card" onclick=cardClick(7);; id="card7">{*[ReadOnly_Script]*}</td>
			<td width=2></td>
		</tr>
		<tr>
			<td valign="middle" colspan="13" bgcolor="#ffffff" align="center"
				width="100%">

			<table border=1 cellpadding=3 cellspacing=1 class="content"
				width="100%" id="content1">

				<tr>
					<td class="commFont commLabel">{*[Name]*}:</td>
					<td><input type=text name="name"
						onchange="checkStartChar(this.value);" /></td>
					<td class="commFont commLabel">{*[TextType]*}:</td>
					<td><select name="textType">
						<option value="text" selected="selected">{*[Common]*}</option>
						<option value="readonly">{*[Readonly]*}</option>
						<option value="hidden">{*[Hidden]*}</option>
						<!-- <option value="layer">层弹出</option> -->
					</select></td>
				</tr>
				<tr>
					<td colspan="4" align="center"><input type=checkbox
						name="refreshOnChanged" value="true">{*[Refresh]*}&nbsp; <input
						type=checkbox name="calculateOnRefresh" value="true">{*[Recalculate]*}&nbsp;
					<input type=checkbox name="mobile" value="true" checked />{*[Mobile]*}&nbsp;
					</td>
				</tr>
				<tr>
					<td class="commFont commLabel">{*[Description]*}:</td>
					<td colspan="3"><textarea name="discript" style="width: 100%"
						rows="7"></textarea></td>
				</tr>
			</table>

			<table border=1 cellpadding=3 cellspacing=1 class="content"
				id="content2">
				<tr>
					<%@include file="commondialog.jsp"%>
				</tr>
			</table>

			<table border=1 cellpadding=3 cellspacing=1 class="content"
				id="content3">
				<tr>
					<td><textarea name="optionsScript" style="width: 96%"
						rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('optionsScript','{*[Script]*}{*[Editor]*}','{*[Option_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
				</tr>
			</table>

			<table border=1 cellpadding=3 cellspacing=1 class="content"
				id="content4">
				<tr>
					<td width="25%">
					<table>
						<tr>
							<td><input type="checkbox" name="validateLibs"
								value="" />checkbox</td>
						</tr>
					</table>
					</td>
					<td width="75%"><textarea name="validateRule"
						style="width: 95%" rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('validateRule','{*[Script]*}{*[Editor]*}','{*[Validate_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
				</tr>
			</table>

			<table border=1 cellpadding=3 cellspacing=1 class="content"
				id="content5">
				<tr>
					<td><textarea name="hiddenScript" style="width: 96%"
						rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('hiddenScript','{*[Script]*}{*[Editor]*}','{*[Hidden_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
				</tr>
				<tr>
						<td>{*[hiddenValue]*}：<input id="hiddenValue" type="text" name="hiddenValue" /></td>
					</tr>
			</table>

			<table border=1 cellpadding=3 cellspacing=1 class="content"
				id="content6">
				<tr>
					<td><textarea name="hiddenPrintScript" style="width: 96%"
						rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('hiddenPrintScript','{*[Script]*}{*[Editor]*}','{*[Hidden_Print_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
				</tr>
				<tr>
						<td>{*[Print]*}{*[hiddenValue]*}：<input  type="text" name="printHiddenValue" /></td>
					</tr>
			</table>

			<table border=1 cellpadding=3 cellspacing=1 class="content"
				id="content7">
				<tr>
					<td><textarea name="readonlyScript" style="width: 96%"
						rows="10"></textarea>
						<button style="border:0px;cursor: pointer;" onclick="openIscriptEditor('readonlyScript','{*[Script]*}{*[Editor]*}','{*[ReadOnly_Script]*}','name','{*[Save]*}{*[Success]*}');"><img alt="Open with IscriptEditor" src="<s:url value='/resource/image/editor.png' />"/></button>
						</td>
				</tr>
			</table>

			</td>
		</tr>
	</table>
	</form>

	<script language=javascript>
	cardClick(1);
</script>
	</BODY>
</x:multiLanguage>
</HTML>
